﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using DHQGHN.DAL.DAO;
using DHQGHN.DAL.DAO.MappingDB;
using DHQGHN.DAL.DataMapper;
using DHQGHN.DAL.Models;
using DHQGHN.DAL.Models.MappingDB;

namespace DHQGHN.DAL.BO.MappingDB
{
    public class SDBGetReportFormBO : BaseBO
    {
        #region Field Name in return DataSet
        //Field Name in return DataSet
          public const string Field_SourceTable = "SourceTable";
        public const string Field_ExtractDate = "ExtractDate";
        public const string Field_StartTime = "StartTime";
        public const string Field_EndTime = "EndTime";
        public const string Field_TotalSourceRow = "TotalSourceRow";
        public const string Field_TotalSuccessRow = "TotalSuccessRow";
        public const string Field_TotalErrRow = "TotalErrRow";
        public const string Field_ErrorMsg = "ErrorMsg";
        public const string Field_DestinationTable = "DestinationTable";
        public const string Field_SessionId = "SessionId";    
        
        #endregion


        public String _connectionString;
        private SDBGetReportFormDAO _shareDAO;
        public SDBGetReportFormBO(string connString)
        {
            this._connectionString = connString;

        }
        public SDBGetReportFormBO()
        {
            this._connectionString = DEFAULT_CONN_STRING;

        }

        public SDBGetReportFormDAO CreateSQLDAO()
        {
            return new SDBGetReportFormDAO(_connectionString, DEFAULT_MAPPER_TYPE);
        }

       
        public List<SDBGetReportForm> GetAllSDBReportForm()
        {
            try
            {
                _shareDAO = CreateSQLDAO();
                Dictionary<String, String> mapDictionary = new Dictionary<string, string>()
                {
                    {SDBGetReportForm.Field_SourceTable,Field_SourceTable},
                    {SDBGetReportForm.Field_ExtractDate,Field_ExtractDate},
                    {SDBGetReportForm.Field_StartTime,Field_StartTime},
                    {SDBGetReportForm.Field_EndTime,Field_EndTime},
                    {SDBGetReportForm.Field_TotalSourceRow,Field_TotalSourceRow},
                    {SDBGetReportForm.Field_TotalSuccessRow,Field_TotalSuccessRow},
                    {SDBGetReportForm.Field_TotalErrRow,Field_TotalErrRow},
                    {SDBGetReportForm.Field_ErrorMsg,Field_ErrorMsg},
                    {SDBGetReportForm.Field_DestinationTable,Field_DestinationTable},
                    {SDBGetReportForm.Field_DestinationTable,Field_SessionId}

                                   
                    
                };
                return _shareDAO.GetAllSDBReportForm(mapDictionary);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public List<SDBGetReportForm> GetAllSDBReportBySessionID(long? sessionID)
        {
            try
            {
                _shareDAO = CreateSQLDAO();
                Dictionary<String, String> mapDictionary = new Dictionary<string, string>()
                {
                    {SDBGetReportForm.Field_SourceTable,Field_SourceTable},
                    {SDBGetReportForm.Field_ExtractDate,Field_ExtractDate},
                    {SDBGetReportForm.Field_StartTime,Field_StartTime},
                    {SDBGetReportForm.Field_EndTime,Field_EndTime},
                    {SDBGetReportForm.Field_TotalSourceRow,Field_TotalSourceRow},
                    {SDBGetReportForm.Field_TotalSuccessRow,Field_TotalSuccessRow},
                    {SDBGetReportForm.Field_TotalErrRow,Field_TotalErrRow},
                    {SDBGetReportForm.Field_ErrorMsg,Field_ErrorMsg},
                    {SDBGetReportForm.Field_DestinationTable,Field_DestinationTable},
                    {SDBGetReportForm.Field_SessionId,Field_SessionId}

                                   
                    
                };
                return _shareDAO.GetAllSDBReportBySessionID(sessionID, mapDictionary);
            }
            catch (Exception e)
            {
                throw e;
            }
        }

    }
}
